package genetic_algorithm;

import java.util.Map.Entry;

/**
 * Interface of the crossover phase in a genetic algorithm
 */
public interface Crossover {
	
	/**
	 * Gets a pair of two parent chromosomes, and creates a new pair
	 * of chromosomes (which are their offsprings).
	 * The parent chromosomes are combined in given rate. If new chromosomes
	 * were created, each offspring is mutated in given rate.
	 * If no chromosomes were created, the parent chromosomes are not mutated
	 * and returned unchanged
	 * @param parents chromosome pair to create the offsprings
	 * @param crossoverRate chance for a crossover (otherwise, returns parents)
	 * @param mutator object implementing the mutation
	 * @param mutationRate chance for a mutation
	 * @return resulting chromosome pair
	 */
	public Entry<Chromosome, Chromosome> mate(
			Entry<Chromosome, Chromosome> parents, double crossoverRate,
			Mutation mutator, double mutationRate);
}
